import QtQuick 2.6
import Sailfish.Silica 1.0
import "../config"

Rectangle {
    property string pageContent: "斗帝 萧炎"
    property string chapterName: "第一章 陨落的天才"
    property int textSize: 50
    property int letterSpacing: 8
    property int bottomPadding: 0
    property int horizontalPadding: 30

    width: parent.width
    height: parent.height
    color: AppColor.themeMode.transparent

    Column {
        anchors.fill: parent
        anchors.leftMargin: horizontalPadding
        anchors.rightMargin: horizontalPadding
        anchors.bottomMargin: bottomPadding
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter
        spacing: 0
        clip: true

        //小说标题
        Label {
            id:chapterNameLabel
            text: chapterName
            width: parent.width
            color: AppColor.themeMode.thirdColor
            horizontalAlignment: Text.AlignHCenter
            topPadding: 20
            bottomPadding: 20
            z:1
        }

        //小说当前页的内容
        Text {
            id: pageContentText
            width: parent.width
            height: parent.height - chapterNameLabel.implicitHeight
            font.pixelSize:textSize
            font.letterSpacing: letterSpacing
            wrapMode: Text.Wrap
            text: pageContent
            color: AppColor.themeMode.secondaryColor
            clip: true

            Component.onCompleted: {
                console.log("父级高度："+parent.height+",标题高度："+chapterNameLabel.implicitHeight+",小说内容高度："+pageContentText.height)
            }
        }
    }


    // 监听父组件的 fontChangeRequested 信号
    Connections {
        target: readPage  // 绑定到父组件（假设父组件的 id 是 rootPage）
        onNovelContentFontChangeSignal: {
            pageContentText.font.pixelSize +=amount
        }
    }
}
